package interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;

/**
 * Created by XingYang on 2018/6/10.
 */
public class LoginCheck implements Interceptor {
    @Override
    public void intercept(Invocation inv) {
        Controller controller = inv.getController();
        if(controller.getSessionAttr("username") != null){
            inv.invoke();
        }else {
            controller.redirect("/login");
        }
    }
}
